#ifndef MobileStorageWIDGET_H
#define MobileStorageWIDGET_H

#include <QWidget>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QLabel>
#include <QPushButton>
#include <QScrollArea>
#include "fileinfo.h"

#include "mobilestorageviewwidget.h"
#include "searchedit.h"
#include "publicattributes.hpp"

class MobileStorageWidget : public QWidget
{
    Q_OBJECT
public:
    MobileStorageWidget(const QMap<QString, FileInfo> &listStruct, QString tabBarPath, int index, QWidget *parent = nullptr);
    ~MobileStorageWidget();

    enum FILE_TYPE {
        None = 0,
        Mobile,  // 手机连接
        Search,  // 搜索
        Pctopc,  // Pc连接
    };

    void setMode(QListView::ViewMode mode);

    void setViewHeight();

    void setTheme(PublicAttributes::Theme theme);

public:
private Q_SLOTS:
    void slotModeButtonClicked();
    void slotFileName(QString fileNamePath);
    void slotLocalPathList(const QStringList &localPathList);
    void slotMenuFileName(QString fileName);
    void slotHideCopyToComputerWidget();
    void slotShowCopyButtonWidget();
Q_SIGNALS:
    void sigFileName(QString fileNamePath);
    void sigShowMobileStorage();
    void sigCurrentIndexPath(QString currentIndexPath);
    void sigLocalPathList(const QStringList &localPathList);
    void sigUpdateClicked(QString);
    void sigModeChange(QListView::ViewMode);
    void sigMenuFileName(QString fileName);
    void sigSetLastWidget();
    void sigChooseFilePath(QString fileName, const QList<FileInfo> &selectFileNameList);
    void sigViewHeight();

private:
    MobileStorageViewWidget *m_mobileStorageViewWidget = nullptr;
//    SearchEdit *m_searchLine = nullptr;
//    QPushButton *m_searchButton = nullptr;
//    QPushButton *m_editButton = nullptr;
//    QFrame *m_verticalLineFrame = nullptr;
    QPushButton *m_modeButton = nullptr;
    QListView::ViewMode m_mode = QListView::IconMode;
    //面包屑的标题路径
    QString m_tabBarPath;
    QMap<QString, FileInfo> m_listStruct;
    QString m_currentIndexPath;
    CopyToComputerButtonWidget *m_copyButtonMobileStrorageWidget = nullptr;
    int m_index = FILE_TYPE::None;
    QScrollArea *m_scrollArea = nullptr;

private:
    void initUI();
    void initSearchUI();
    void initPcUI();
    void initConnect();
    void moveCopyToComputerWidget();
    void setEditFocus(bool focus);
};

#endif // MobileStorageWIDGET_H
